﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;

namespace Lilium.Web.Mvc.AjaxControlToolkit
{
	[RequiredResource(typeof(CommonToolkitScripts))]
	[RequiredResource(typeof(AnimationScripts))]
	[ToolkitScriptReference("Accordion.AccordionBehavior.js", LoadOrder = 1)]
	public class AccordionExtender: ToolkitExtenderBase
	{
		public AccordionExtender(string elementID)
			: base("AjaxControlToolkit.AccordionBehavior", elementID)
		{
		}

		#region public AutoSize AutoSize

		private AutoSize m_AutoSize = AutoSize.None;

		/// <summary>
		/// Determine how growth of the Accordion will be controlled.  If it is set to
		/// None, then the Accordion can grow as large or as small as necessary.  If it is
		/// set to Limit, then the Accordion will always be less than or equal to its
		/// Height.  If it is set to Fill then it will always be equal to its height.
		/// </summary>
		[ExtenderControlProperty]
		[DefaultValue(AutoSize.None)]
		public AutoSize AutoSize { [DebuggerNonUserCodeAttribute] get { return m_AutoSize; } [DebuggerNonUserCodeAttribute] set { m_AutoSize = value; } }

		#endregion

		#region public int TransitionDuration

		private int m_TransitionDuration = 250;

		/// <summary>
		/// Length of transition between accordion panes in milliseconds
		/// </summary>
		[ExtenderControlProperty]
		[DefaultValue(250)]
		public int TransitionDuration { [DebuggerNonUserCodeAttribute] get { return m_TransitionDuration; } [DebuggerNonUserCodeAttribute] set { m_TransitionDuration = value; } }

		#endregion

		#region public bool FadeTransitions

		private bool m_FadeTransitions;

		/// <summary>
		/// Whether or not to use a fade effect when transitioning between selected
		/// Accordion Panes
		/// </summary>
		[ExtenderControlProperty]
		[DefaultValue(false)]
		public bool FadeTransitions { [DebuggerNonUserCodeAttribute] get { return m_FadeTransitions; } [DebuggerNonUserCodeAttribute] set { m_FadeTransitions = value; } }

		#endregion

		#region public int FramesPerSecond

		private int m_FramesPerSecond = 30;

		/// <summary>
		/// The number of frames per second used in the transition animation effects.
		/// This is used to tune performance when using FadeTransition, a large number
		/// of Accordion Panes, etc.
		/// </summary>
		[ExtenderControlProperty]
		[DefaultValue(30)]
		public int FramesPerSecond { [DebuggerNonUserCodeAttribute] get { return m_FramesPerSecond; } [DebuggerNonUserCodeAttribute] set { m_FramesPerSecond = value; } }

		#endregion

		#region public int SelectedIndex

		private int m_SelectedIndex;

		/// <summary>
		/// Index of the AccordionPane that is currently selected for display
		/// </summary>
		//TODO: возможно имеет смысл добавить какой-нибудь способ передачи выбранного индекса на сервер
		[ExtenderControlProperty]
		[DefaultValue(0)]
		public int SelectedIndex
		{
			[DebuggerNonUserCodeAttribute]
			get
			{
				return m_SelectedIndex;
			}
			[DebuggerNonUserCodeAttribute]
			set
			{
				m_SelectedIndex = value;
			}
		}

		#endregion

		#region public bool RequireOpenedPane

		private bool m_RequireOpenedPane = true;

		/// <summary>
		/// Whether or not clicking the header will close the currently opened pane (which leaves
		/// all the Accordion's panes closed)
		/// </summary>
		[ExtenderControlProperty]
		[DefaultValue(true)]
		[ClientPropertyName("requireOpenedPane")]
		public bool RequireOpenedPane { [DebuggerNonUserCodeAttribute] get { return m_RequireOpenedPane; } [DebuggerNonUserCodeAttribute] set { m_RequireOpenedPane = value; } }

		#endregion

		#region public bool SuppressHeaderPostbacks

		private bool m_SuppressHeaderPostbacks;

		/// <summary>
		/// Whether or not we suppress the client-side click handlers of any elements (including server
		/// controls like Button or HTML elements like anchor) in the header sections of the Accordion.
		/// </summary>
		[ExtenderControlProperty]
		[DefaultValue(false)]
		[ClientPropertyName("suppressHeaderPostbacks")]
		[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Postbacks", Justification = "ASP.NET term")]
		public bool SuppressHeaderPostbacks { [DebuggerNonUserCodeAttribute] get { return m_SuppressHeaderPostbacks; } [DebuggerNonUserCodeAttribute] set { m_SuppressHeaderPostbacks = value; } }

		#endregion

		#region public string HeaderCssClass

		private string m_HeaderCssClass;

		/// <summary>
		/// Default Header CSS Class
		/// </summary>
		[ExtenderControlProperty]
		[DefaultValue("")]
		public string HeaderCssClass { [DebuggerNonUserCodeAttribute] get { return m_HeaderCssClass ?? string.Empty; } [DebuggerNonUserCodeAttribute] set { m_HeaderCssClass = value; } }

		#endregion

		#region public string HeaderSelectedCssClass

		private string m_HeaderSelectedCssClass;

		/// <summary>
		/// Default selected Header CSS Class
		/// </summary>
		[ExtenderControlProperty]
		[DefaultValue("")]
		public string HeaderSelectedCssClass { [DebuggerNonUserCodeAttribute] get { return m_HeaderSelectedCssClass ?? string.Empty; } [DebuggerNonUserCodeAttribute] set { m_HeaderSelectedCssClass = value; } }

		#endregion

		#region public string ContentCssClass

		private string m_ContentCssClass;

		/// <summary>
		/// Default Content CSS Class
		/// </summary>
		[ExtenderControlProperty]
		[DefaultValue("")]
		public string ContentCssClass { [DebuggerNonUserCodeAttribute] get { return m_ContentCssClass ?? string.Empty; } [DebuggerNonUserCodeAttribute] set { m_ContentCssClass = value; } }

		#endregion
	}
}